import React from 'react';
import {Route, Switch} from 'react-router-dom';
import {createStore, combineReducers, applyMiddleware} from 'redux';
import {Provider} from 'react-redux';
import {routerReducer, routerMiddleware, ConnectedRouter} from 'react-router-redux';
import {createBrowserHistory} from 'history';
import reducers from './reducers';
import {ConfigProvider} from 'antd';
import zh_CN from 'antd/lib/locale-provider/zh_CN';
// import "antd/dist/antd.css";
import "./css/index.css";
import "./themes.less";
import Main from './views/IndexMain';
import Login from './views/Login';
import {config} from './config';
import {composeWithDevTools} from 'redux-devtools-extension';

const history = createBrowserHistory();
const middleware = routerMiddleware(history);

const store = createStore(
    combineReducers({
        ...reducers,
        routerReducer
    }),
    composeWithDevTools(applyMiddleware(middleware))
);

const Index = () => {
    return (
        <ConfigProvider locale={zh_CN}>
            <Provider store={store}>
                <ConnectedRouter history={history}>
                    <Switch>
                        <Route path={config.path + "/main"} component={Main}/>
                        <Route component={Login}/>
                    </Switch>
                </ConnectedRouter>
            </Provider>
        </ConfigProvider>
    );
};

export default Index;
